import requests

class APIClient:
    def __init__(self, api_key, base_url):
        self.api_key = api_key
        self.base_url = base_url
        self.headers = {"Authorization": f"Bearer {api_key}"}

    def post_request(self, endpoint, data):
        response = requests.post(
            f"https://api.deepseek.com/{endpoint}",
            headers={
                "Content-Type": "application/json",
                "Authorization": f"Bearer {self.api_key}"
            },
            json=data
        )
        print("API Response:", response.text)  # 打印调试信息
        if response.status_code != 200:
            raise Exception(f"API Error: {response.status_code}, {response.text}")
        try:
            return response.json()
        except ValueError as e:
            raise Exception(f"Failed to decode JSON: {e}, Response: {response.text}")